<template>
  <div class="app-container">
    <h4 class="h4" style="font-weight: bold">基本信息</h4>
    <el-form ref="form" :model="form" label-width="80px">
      <el-row>
        <el-col :span="2">
          <img :src="form.headUrl" alt="" style="width: 60px;height: 60px;border-radius: 50%;background: #f5f5f5;">
        </el-col>
        <el-col :span="21" >
          <el-row style="margin-bottom: 20px">
            <el-col :span="6">
              <span>用户ID：{{ form.userId }}</span>
            </el-col>
            <el-col :span="6">
              <span>用户名：{{ form.username }}</span>
            </el-col>
            <el-col :span="6">
              <span>注册日期：{{ form.registerDate }}</span>
            </el-col>
            <el-col :span="6">
              <span>用户类型：{{ form.userType }}</span>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <span>来源渠道：{{ form.source }}</span>
            </el-col>
            <el-col :span="6">
              <span>登录方式：{{ form.loginType }}</span>
            </el-col>
            <el-col :span="6">
              <span>最后登录：{{ form.lastLoginDate }}</span>
            </el-col>
          </el-row>
        </el-col>
      </el-row>
    </el-form>
    <h4 class="label h4" style="font-weight: bold">会员信息</h4>
    <p>会员期限：{{ form.memberDate }}</p>
    <h4 class="h4">支付记录</h4>
    <el-table v-loading="loading" ref="table" :data="list">
      <el-table-column label="订单号" align="center" prop="orderNum" width="200" />
      <el-table-column label="支付金额" align="center" prop="payAmount">
        <template slot-scope="scope">
          <span>￥{{ scope.row.payAmount }}</span>
        </template>
      </el-table-column>
      <el-table-column label="充值时间" align="center" prop="payDate">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.payDate) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="到期时间" align="center" prop="expireDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.expireDate) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="支付方式" align="center" prop="payType">
        <template slot-scope="scope">
          <span>{{ scope.row.payType === '1' ? '支付宝' : '微信' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="购买类型" align="center" prop="memberName" />
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="pageNum" :limit.sync="pageSize" />

    <el-form label-width="100px">
      <el-form-item style="text-align: center;margin-left:-120px;margin-top:30px;">
        <el-button @click="close()">返回</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { getAppUserDetail } from "@/api/shuiyin/shuiyin";

export default {
  name: "UserDetail",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 分页信息
      total: 0,
      pageNum: 1,
      pageSize: 10,
      // 选中角色编号
      roleIds:[],
      // 角色信息
      list: [],
      // 用户信息
      form: {}
    };
  },
  created() {
    const userId = this.$route.params && this.$route.params.userId;
    if (userId) {
      this.loading = true;
      getAppUserDetail(userId, {pageNum: 1,pageSize: 10}).then((response) => {
        this.form = response.data.userInfo;
        this.list = response.data.payRecords.records;
        this.total = response.data.payRecords.total;
        this.loading = false;
      });
    }
  },
  methods: {
    /** 单击选中行数据 */
    clickRow(row) {
      this.$refs.table.toggleRowSelection(row);
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.roleIds = selection.map((item) => item.roleId);
    },
    // 保存选中的数据编号
    getRowKey(row) {
      return row.roleId;
    },
    /** 关闭按钮 */
    close() {
      this.$store.dispatch("tagsView/delView", this.$route);
      this.$router.push({ path: "/info" });
    },
  },
};
</script>
